Strategy Pattern
The Strategy Pattern encapsulates interchangeable algorithms behind a common interface and allows the algorithm to be selected independently of the client. It is particularly effective when a method contains a growing if/else or switch statement representing different business rules. Instead of repeatedly modifying the client, I introduce a strategy per behavior and inject or select the required strategy.
Encapsulates algorithms behind a common abstraction.
Removes growing conditional logic from the context class.
Strategies can be tested independently.
New strategies can often be added without changing existing client logic.
Use it when behavior genuinely varies; avoid it for trivial one-off conditions.